import { transform, isObject, isArray, isNil } from 'lodash';

export function rmNilValues(obj: Record<string, any>) {
  return transform(obj, (result, value, key) => {
    if (isObject(value) && !isArray(value)) {
      value = rmNilValues(value);
    }
    if (!isNil(value)) {
      result[key] = value;
    }
  });
}
